package com.ruicar.afs.cloud.basic.common.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruicar.afs.cloud.basic.common.condition.ContractBasicListVO;
import com.ruicar.afs.cloud.basic.common.condition.QueryContractListCondition;
import com.ruicar.afs.cloud.basic.common.service.BasicMainInfoService;
import com.ruicar.afs.cloud.common.core.util.IResponse;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author: Lee
 * @date: 2020/5/11 19:39
 * @description: 页面弹框数据查询(公共)
 */
@Slf4j
@RestController
@RequestMapping("/alertTable")
@AllArgsConstructor
public class BasicAlertTableController {

    private final BasicMainInfoService basicMainInfoService;

    @ApiOperation(value = "新增申请弹框页面统一数据查询接口")
    @PostMapping("/getAlertTableData")
    public IResponse<IPage<List<ContractBasicListVO>>> getAlertTableData(@RequestBody QueryContractListCondition condition){
        List<ContractBasicListVO> activatedContractList = basicMainInfoService.findActivatedContractList(condition);
        Integer count = basicMainInfoService.findActivatedContractCount(condition);
        Map map = new HashMap();
        map.put("total",count);
        map.put("size",condition.getPageSize());
        map.put("current",condition.getPageIndex());
        map.put("records",activatedContractList);
//        basicMainInfoService.findActivatedContractList(new Page(condition.getPageNumber(), condition.getPageSize()), condition)

        return new IResponse().setData(map);
    }

}
